<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>建议使用学习帮APP</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        html,body{
            height: 100%;
        }
        ul li{
            list-style: none;
        }
        a{
            text-decoration: none;
            
        }
        a:link{
            color: #404040;
        }
        a:visited{
            color: #404040;
        }
        a:hover{
            color: #404040;
        }
        a:active{
            color: #404040;
        }
        ::-webkit-scrollbar{
            /* width: 0; 移动端取消滚动条无效*/
            display: none;
        }
        body{
            background: #f4f4f4;/*#2493f1*/
            display: flex;
            flex-direction: column;
            font-family: 微软雅黑;
            font-size: .3865rem;
            letter-spacing: .0169rem;
            position: relative;
            overflow: hidden;/*禁止上下滑动*/
            -webkit-user-select:none;
            -moz-user-select:none;
            -ms-user-select:none;
            user-select:none;
        }
        
        section{/*
            border: 1px solid red;*/
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            overflow: scroll;
        }
        .container{
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            box-sizing: border-box;
        }
        .container span.title{
            /*
            border: 1px solid red;*/
            width: 90%;
            font-size: .4348rem;
            font-weight: 550;
            margin: .3623rem 0;
        }
        .ul{
            /*
            border: 1px solid red;*/
            width: 90%;
            margin-bottom: .4831rem;
        }
        .ul li{
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .ul span.className, .ul span.result{
            width: 100%;
            display: flex;
            flex-direction: row;
            justify-content: left;
            font-size: .3865rem;
            margin-bottom: .2415rem;
        }
        /**/
        li textarea{
            box-sizing: border-box;
            border-radius: .1208rem;
            width: 100%;
            margin: .2415rem 5%;
            padding: .2415rem;
            color: #b9bec7;
            background: #282c34;
            font-size: .3623rem;
        }
        .imgBox{
            width: 100%;
        }
        .imgBox img{
            width: 100%;
            margin-bottom: .2415rem;
        }
        li button{
            width: 100%;
            height: .9662rem;
            background: #2493f1;
            color: #fff;
            font-size: .3865rem;
            letter-spacing: .0169rem;
            border: none;
            border-radius: .1208rem;
            margin: .4831rem 0;
        }
        
        
        
        

        









        


        
    </style>
    <link rel="stylesheet" href="../../../../../css/header.css">
    <link rel="stylesheet" href="../../../../../css/alert.css">
    <!-- 引入样式文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.2/lib/index.css" />
    
    <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>
    <script src="../../../../../lib/jquery.min.js"></script>
    <script src="../../../../../lib/vue.js"></script>
    
</head>
<body>
    <header>
        <div class="backBtn"></div>
        <div class="left"></div>
        <span class="title">实验五-使用动态网页删除一条记录</span>
    </header>
    <script>
        document.querySelector(".backBtn").onclick=function(){
            window.history.go(-1)
        }
    </script>
    <section>
        <div class="container">
            <ul class="ul" style="margin-top: .3623rem;">
                <span class="result">项目结构</span>
                <div class="imgBox">
                    <img src="./img/xmjg.png" alt="">
                </div>
            </ul>
            
            <span class="title">
                一、新建动态网页项目test5
            </span>
            <ul class="ul ul1">
                <li>
                    <span class="className">1. 在File -> New -> Other 找到 Web 下的 Dynamic Web Project项目模板，点击Next进入下一步</span>
                    <div class="imgBox">
                        <img src="./img/step1.png" alt="">
                    </div>
                    <div class="imgBox">
                        <img src="./img/step2.png" alt="">
                    </div>
                    <span class="className">2. 给新建的项目命名test5，点击Next进入下一步</span>
                    <div class="imgBox">
                        <img src="./img/step3.png" alt="">
                    </div>
                    <span class="className">3. 无需修改默认配置，直接点击Next进入下一步</span>
                    <div class="imgBox">
                        <img src="./img/step4.png" alt="">
                    </div>
                    <div class="imgBox">
                    <span class="className">4. 勾选Generate web.xml deployment descriptor，自动生成web.xml，点击Finish完成</span>
                    <img src="./img/step5.png" alt="">
                    </div>
                </li>
                
           </ul>

            <span class="title">
                二、添加jdbc驱动
            </span>
            <ul class="ul ul1">
                <li>
                    <span class="className">1. 直接找到之前使用过jdbc的项目，复制其WEB-INF文件夹下的lib文件夹中的jdbc驱动包</span>
                    <div class="imgBox">
                        <img src="./img/step6.png" alt="">
                    </div>
                    <span class="className">2. 将复制好的jdbc驱动包直接粘贴到新建test5项目的WEB-INF文件夹下的lib文件夹中即可</span>
                    <div class="imgBox">
                        <img src="./img/step7.png" alt="">
                    </div>
                    <div class="imgBox">
                        <img src="./img/step8.png" alt="">
                    </div>
                </li>
                
           </ul>

            <span class="title">
                三、新建teacherView.jsp
            </span>
            <ul class="ul ul1">
                <li>
                    <span class="className">1. 在webapp目录下New -> JSP File</span>
                    <div class="imgBox">
                        <img src="./img/step9.png" alt="">
                    </div>
                    <span class="className">2. 给新建的jsp文件命名teacherView.jsp，点击Finish完成</span>
                    <div class="imgBox">
                        <img src="./img/step10.png" alt="">
                    </div>
                </li>
                
           </ul>
            
            <ul class="ul ul1">
                <li>
                    <span class="className">teacherView.jsp</span>
                    <textarea name="" class="txt1" cols="30" rows="10"></textarea>
                    <button id="txt1" onclick="copy(event)">一键复制</button>
                </li>
                
           </ul>

            <span class="title">
                四、新建deleteTeacher.java
            </span>
            <ul class="ul ul1">
                <li>
                    <span class="className">1. 在Java Resources目录下的src/main/java目录New -> Servlet</span>
                    <div class="imgBox">
                        <img src="./img/step11.png" alt="">
                    </div>
                    <span class="className">2. 给新建的servlet文件命名deleteTeacher，点击Finish完成</span>
                    <div class="imgBox">
                        <img src="./img/step12.png" alt="">
                    </div>
                </li>
                
           </ul>

           <ul class="ul ul1">
            <li>
                <span class="className">deleteTeacher.java</span>
                <textarea name="" class="txt2" cols="30" rows="10"></textarea>
                <button id="txt2" onclick="copy(event)">一键复制</button>
                <span class="result">运行结果</span>
                <span class="className">运行teacherView.jsp文件，在浏览器网页中显示教师表数据，且可成功删除表中数据</span>
                <div class="imgBox">
                    <img src="./img/step13.png" alt="">
                </div>
                <div class="imgBox">
                    <img src="./img/step14.png" alt="">
                </div>
            </li>
            
       </ul>
       





           
        </div>
         
        
      
        <!-- 图片预览组件 -->
        <van-image-preview v-model="show" :images="images">
        </van-image-preview>
        
    </section>


    <script>
        function copy(e) {
            console.log(e.target.id)
            var element = document.querySelector("."+e.target.id);
            var copyBtn = document.getElementById(e.target.id);
            element.select();
            element.setSelectionRange(0, element.value.length);
            document.execCommand('copy');
            copyBtn.style.background='#c0c0c0'
            copyBtn.innerHTML='已复制'
            setTimeout(function(){
                copyBtn.style.background='#2493f1'
                copyBtn.innerHTML='一键复制'
            },2000)
        }
    </script>
    <script>
        document.addEventListener('visibilitychange',
        function(){
            if(document.visibilityState === "visible"){
                setTimeout(()=>{
                    location.reload()
                }, 1000)
            }
        }
        )
    </script>
    <!-- 引入vant.js -->
    <script src="https://cdn.jsdelivr.net/npm/vant@2.2/lib/vant.min.js"></script>

    <script>
        new Vue({
            el: 'section',
            data: {
                //组件
                //show: true, //弹窗组件
                show: false, //图片预览组件
                index: 0,
                images: [],
            },
            methods: {
                pay(){
                    this.$toast.setDefaultOptions({ duration: 20000 })
                    let toast1 = this.$toast.loading({
                        message: '加载中...',
                        forbidClick: true,
                        loadingType: 'circular'
                        });


                    let _this = this
                    fetch(`https://fc-mp-e8e2bde5-0c0c-4622-87b5-66f8b08c3856.next.bspapp.com/encryption/getPK309?name=数据库技术A_实验五&userid=${JSON.parse(localStorage.getItem('XGB-user')).id}`)
                    .then(res => res.json())
                    .then(res=>{
                        if(res.code === 0){
                            let sign = md5(`${res.data[0]}${res.data[1]}`)
                            fetch(`https://fc-mp-e8e2bde5-0c0c-4622-87b5-66f8b08c3856.next.bspapp.com/encryption/putVK309?name=数据库技术A_实验五&userid=${JSON.parse(localStorage.getItem('XGB-user')).id}&vk=${res.data[2]}&sign=${sign}`)
                            .then(res=>{
                            })
                            let url = `https://7-pay.cn/submit.php?${res.data[0]}&sign=${sign}&sign_type=MD5`
                            console.log(url)
                            toast1.clear()
                            window.location.replace(url)
                        }else{
                            toast1.clear()
                            document.body.innerHTML=res.warning
                            document.title='违规行为警告'
                        }
                    })
                },
                readTxt(t, el) {
                    $.get(`https://mp-e8e2bde5-0c0c-4622-87b5-66f8b08c3856.cdn.bspapp.com/code/work/sjkjsa_2023/test5/${t}.txt`,function(data) { 
                        document.querySelector(el).value=data
                    });
                },
                ImagePreview(url) {
                    this.show = true
                    this.images = [url]
                }
            },
            mounted() {
                let imageList = document.querySelectorAll("img")
                let _this = this
                for(let i = 0; i < imageList.length; i++) {
                    imageList[i].addEventListener('click',function(){
                        let url = imageList[i].getAttribute('src')
                        _this.ImagePreview(url)
                    })
                }
                //获取支付状态
                fetch(`https://fc-mp-e8e2bde5-0c0c-4622-87b5-66f8b08c3856.next.bspapp.com/encryption/getBI309?name=数据库技术A_实验五&userid=${JSON.parse(localStorage.getItem('XGB-user')).id}`)
                .then(res => res.json())
                .then(res=>{
                    if (res.code !== 0) {//未支付
                        var userBrowser = navigator.userAgent.toLowerCase()
                        //if (userBrowser.match(/MicroMessenger/i) == "micromessenger"){
                        if(true){
                            fetch(`https://fc-mp-e8e2bde5-0c0c-4622-87b5-66f8b08c3856.next.bspapp.com/encryption/getPC309?name=数据库技术A_实验五&userid=${JSON.parse(localStorage.getItem('XGB-user')).id}`)
                            .then(res => res.json())
                            .then(res=>{
                                if(res.code === 0){
                                    this.$dialog.confirm({
                                        title: '提示',
                                        message: `当前为付费资源，是否支付￥${res.data}元购买【数据库技术A_实验五】？`,
                                        confirmButtonText: '支付',
                                        cancelButtonText: '取消'
                                      })
                                        .then(() => {
                                          // on confirm
                                          this.pay()
                                        })
                                        .catch(() => {
                                          // on cancel
                                            document.body.innerHTML=''
                                            window.history.go(-1)
                                        });
                                }else{
                                    document.body.innerHTML=""
                                    document.body.innerHTML=res.warning
                                    document.title='违规行为警告'

                                }
                            })
                            
                        }else{
                            
                        }
                    }else if (res.code === 0) {
                        this.readTxt('teacherView.jsp', '.txt1')
                        this.readTxt('deleteTeacher.java', '.txt2')
                    }
                })
                

            }
        })
    </script>
    
    <script>
        function resetHtmlFont(){
            document.documentElement.style.fontSize = screen.width/10 + 'px';
        }
        resetHtmlFont();
        window.onresize = resetHtmlFont;
    </script>
</body>
</html>